import { Navigate } from 'react-router-dom'
// 只能导入，不能使用箭头函数的方式导入
import Main from '../pages/main'
import Home from '../pages/home/home'
import Mall from '../pages/mall'
import User from '../pages/user'
import pageOne from '../pages/other/pageOne'
import pageTwo from '../pages/other/pageTwo'

const routes = [
    {
        path: '/',
        Component: Main,
        children: [
            // 重定向
            {
                path: '/',
                element: <Navigate to='home' replace></Navigate>
            },
            {
                path: '/home',
                name: 'home',
                Component: Home,
            },
            {
                path: '/mall',
                name: 'mall',
                Component: Mall
            },
            {
                path: '/user',
                name: 'user',
                Component: User
            },
            {
                path: 'other',
                children: [
                    {
                        path: 'page-one',
                        name: 'page-one',
                        Component: pageOne
                    },
                    {
                        path: 'page-two',
                        name: 'page-two',
                        Component: pageTwo
                    }
                ]
            }
        ]
    }
]

export default routes